package com.yuan.yblog.security.config;

import com.yuan.yblog.security.component.JwtAuthenticationTokenFilter;
import com.yuan.yblog.security.handler.RestAuthenticationEntryPoint;
import com.yuan.yblog.security.handler.RestfulAccessDeniedHandler;
import com.yuan.yblog.security.util.JwtTokenUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *  统一创建有关Security的Bean对象
 */
@Configuration
public class BeanManager {

    @Bean
    public JwtTokenUtil jwtTokenUtil() {
        return new JwtTokenUtil();
    }

    @Bean
    public IgnoreUrlsConfig ignoreUrlsConfig() {
        return new IgnoreUrlsConfig();
    }

    @Bean
    public JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter(){
        return new JwtAuthenticationTokenFilter();
    }

    @Bean
    public RestfulAccessDeniedHandler restfulAccessDeniedHandler() {
        return new RestfulAccessDeniedHandler();
    }

    @Bean
    public RestAuthenticationEntryPoint restAuthenticationEntryPoint() {
        return new RestAuthenticationEntryPoint();
    }
}
